﻿# Once done, this will define
#
# WOLFSSL_INCLUDE_DIR - theWOLFSSL include directory
# WOLFSSL_LIBRARY_DIR - theWOLFSSL library directory
# WOLFSSL_LIBS - link these to useWOLFSSL
#
#  ......

MACRO(load_wolfssl os arch)
    MESSAGE(INFO "--------------------------------")
    SET(3RDPARTY_DIR ${PROJECT_SOURCE_DIR}/3rdparty/target/${${os}}_${${arch}})
    MESSAGE(STATUS "3RDPARTY_DIR: ${3RDPARTY_DIR}")
    #FIND_FILE(WOLFSSL_INCLUDE_DIR include ${3RDPARTY_DIR} NO_DEFAULT_PATH)
    #FIND_FILE(WOLFSSL_LIBRARY_DIR lib ${3RDPARTY_DIR} NO_DEFAULT_PATH)
    SET(WOLFSSL_INCLUDE_DIR ${3RDPARTY_DIR}/include/wolfssl)
    SET(WOLFSSL_LIBRARY_DIR ${3RDPARTY_DIR}/lib/wolfssl)

    IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
        SET(WOLFSSL_LIBS wolfssl)
    ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
       SET(WOLFSSL_LIBS wolfssl)
    ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")

    IF(WOLFSSL_INCLUDE_DIR)
        #SET(WOLFSSL_LIBRARY_DIR "${WOLFSSL_LIBRARY_DIR}/wolfssl")
        #SET(WOLFSSL_LIBS "${WOLFSSL_LIBRARY_DIR}/libwolfssl.a")
        #SET(WOLFSSL_LIBS "${WOLFSSL_LIBRARY_DIR}/libWOLFSSL.so")
        MESSAGE(STATUS "WOLFSSL_INCLUDE_DIR : ${WOLFSSL_INCLUDE_DIR}")
        MESSAGE(STATUS "WOLFSSL_LIBRARY_DIR : ${WOLFSSL_LIBRARY_DIR}")
        MESSAGE(STATUS "WOLFSSL_LIBS : ${WOLFSSL_LIBS}")
    ELSE()
        MESSAGE(FATAL_ERROR "libwolfssl not found!")
    ENDIF()
ENDMACRO()
